'use strict';
const Server = require('egg').Service;

class UserService extends Server {
  async getUser() {
    const res = await this.app.mysql.query('select * from user');
    return res;
  }
  async addUser(name, pwd) {
    return await this.app.mysql.query('insert into user (name, pwd) values (?, ?)', [ name, pwd ]);
  }
  async delUserById(id) {
    return await this.app.mysql.query('delete from user where id = ?', id);
  }
  async getDataById(id) {
    return await this.app.mysql.query('select * from user where id = ?', id);
  }
  async edit(id, name, pwd) {
    return await this.app.mysql.query('update user set name = ?, pwd = ? where id = ?', [ name, pwd, id ]);
  }
}


module.exports = UserService;
